﻿/*
 * Nix PBEM Game Engine.
 * Copyright (C) 2008, Lauris Bukšis-Haberkorns
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

using Nix.PBeM.Engine.DataTypes.Orders;
using System;
using Nix.PBeM.Engine.DataTypes;
using Nix.PBeM.Engine.Process.Orders;

namespace Overlord
{
	class Program
	{
		public static void Main(string[] args)
		{
			Console.WriteLine("Overlord server using Nix PBEM Game Engine v{0}", Nix.PBeM.Engine.Engine.Version.ToString(3));
			Console.WriteLine("Copyright (C) 2008, Lauris Bukšis-Haberkorns");
			Console.WriteLine("This program comes with ABSOLUTELY NO WARRANTY;");
			Console.WriteLine("This is free software, and you are welcome to redistribute it");
			Console.WriteLine("under certain conditions; see license file for details.");
			Console.WriteLine();

			Nix.PBeM.Engine.FileEngine engine;
			if (args.Length > 0)
				engine = new Nix.PBeM.Engine.FileEngine(args[0]);
			else
				engine = new Nix.PBeM.Engine.FileEngine("overlord.config");
			bool ok = engine.LoadData();
			if ( ok )
			{
				engine.SetSupportedOrders(DefaultOrderPrototypes.AllOrders);
				
				engine.LoadAllOrders();
				
				/*// For testing purposes
				Faction f5 = engine.FindFaction(5);
				Faction f6 = engine.FindFaction(6);
				Unit u501 = engine.FindUnit(501);
				f5.AddOrder(engine.CreateOrder(f5, "PASSWORD test"));
				f5.AddOrder(engine.CreateOrder(f5, "NAME Dark knights"));
				f6.AddOrder(engine.CreateOrder(f6, "NAME Evil Lord followers"));
				OrderBase day5 = engine.CreateOrder(u501, "DAY 4");
				u501.AddOrder(day5);
				u501.AddDependant(day5, engine.CreateOrder(u501, "NAME Workers"));*/
			
				engine.Process();

				engine.GenerateReports();

				engine.SaveData();
			}

			Console.Write("Press any key to continue . . . ");
			Console.ReadKey(true);
		}
	}
}